package com.usian.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.activation.DataSource;


@Configuration
public class JdbcConfiguration {

//    @Value("${jdbc.url}")
//    String url;
//    @Value("${jdbc.driverClassName}")
//    String driverClassName;
//    @Value("${jdbc.username}")
//    String username;
//    @Value("${jdbc.password}")
//    String password;
//
//    @Autowired
//    private DbProperties dbProperties;
//
//
//    @Bean
//    public DruidDataSource dataSource() {
//        DruidDataSource dataSource = new DruidDataSource();
//        dataSource.setUrl(dbProperties.getUrl());
//        dataSource.setDriverClassName(dbProperties.getDriverClassName());
//        dataSource.setUsername(dbProperties.getUsername());
//        dataSource.setPassword(dbProperties.getPassword());
//        return dataSource;
//    }

    @Bean

    @ConfigurationProperties(prefix = "jdbc")
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        return dataSource;
    }

}